{% extends 'base.html' %}
{% load staticfiles %}
{% block css %}
    <link rel="stylesheet" type="text/css" href="{% static 'js/plugins/queryCity/css/cityLayout.css' %}">
    {% block mycss %}{% endblock %}
{% endblock %}
{% block middle %}
    <div class="middle companyheader">
        <div class="wp">
            <img class="fl" style="width: 112px;height: 103px" src="/media/{{ org.image }}"/>
            <div class="head fl">
                <h1>
                    {{ org.name }}
                    <img src="{% static 'images/authentication.png' %}"/>
                    <img src="{% static 'images/gold.png' %}"/>
                </h1>
                <p class="fl">
                    <span class="fl" style="margin-top:8px;color:#848484;">推荐指数： </span>
                    <span class="precision company-credit" data-star-scope="5.0"></span>
                    <span class="key">5.0</span>
                </p>
            </div>
            <div class="btn fr collectionbtn  notlogin" data-favid="22" data-fav-type="1" id="love">
                {% if love_status %}
                    取消收藏
                {% else %}
                    收藏
                {% endif %}
            </div>

        </div>
    </div>
{% endblock %}
{% block content %}
    <section>
        <div class="wp">
            <ul class="crumbs">
                <li><a href="/">首页</a>></li>
                <li><a href="/orgs/org_list/">课程机构</a>></li>
                <li>{% block breach %}机构首页{% endblock %}</li>
            </ul>
        </div>
    </section>
    <section>
        <div class="wp list personal_list comp">
            <div class="left">
                <ul>
                    <li {% if detail_type == 'home' %}class="active2"{% endif %}><a
                            href="/orgs/org_detail/{{ org_id }}">机构首页</a></li>
                    <li {% if detail_type == 'course' %}class="active2"{% endif %}><a
                            href="/orgs/org_detail_course/{{ org_id }}">机构课程</a></li>
                    <li {% if detail_type == 'desc' %}class="active2"{% endif %}><a
                            href="/orgs/org_detail_desc/{{ org_id }}">机构介绍</a></li>
                    <li {% if detail_type == 'teacher' %}class="active2"{% endif %}><a
                            href="/orgs/org_detail_teachers/{{ org_id }}">机构讲师</a></li>
                </ul>
            </div>
            {% block right %}{% endblock %}
        </div>
    </section>
{% endblock %}
{% block js %}
    <script type="text/javascript" src="{% static 'js/plugins/jquery.raty.js' %}"></script>
    <script type="text/javascript">
        $(function () {
            var $precision = $('.precision'),
                score = $precision.attr('data-star-scope'),
                option = {
                    half: true,
                    path: '{% static 'images/' %}',
                    precision: true,
                    size: 24,
                    starOff: 'g_star.png',
                    starOn: 'r_star.png',
                    starHalf: 'h_star.png',
                    hints: ['极差', '差', '一般', '好评', '非常满意'],
                    noRatedMsg: '暂时还未获得评价！',
                    readOnly: true,
                    score: score
                };
            $precision.raty(option);

            $("#love").click(function () {
                let love_id = {{ org.id }};
                let love_type = 1;
                $.ajax({
                    type: "GET",
                    url: "/operations/user_love/",
                    data: {
                        "loveid": love_id,
                        "lovetype": love_type,
                    },
                    success: function (callback) {
                        if (callback.status == 'ok') {
                            $("#love").text(callback.msg);
                        }else if(callback.status == 'nologin'){
                            window.location.href = "{% url 'users:user_login' %}";
                        }
                        else {
                            alert(callback.msg);
                        }
                    }
                })
            })
        })
    </script>
    {% block js1 %}{% endblock %}
{% endblock %}
